package com.itheima.reggie.controller;

import com.itheima.reggie.common.ResultInfo;
import com.itheima.reggie.domain.Setmeal;
import com.itheima.reggie.service.SetmealService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController

public class SetmealController {
    @Autowired
    private SetmealService setmealService;
    @GetMapping("/setmeal/list")
    //根据分类列表查询套餐的ID
    @Cacheable(value = "setmeal",key = "#categoryId")//stemeal::categoryId
    public ResultInfo findByCategoryId(Long categoryId ,Integer status){
        System.out.println("从MySQL中查询的");
        List<Setmeal>setmealList = setmealService.findByCategoryId(categoryId,status);
        return ResultInfo.success(setmealList);
    }
}
